﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.roles
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int roles_id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(roles_id);
				}
			}
		}
			
	private void ShowInfo(int roles_id)
	{
		lcs.BLL.roles bll=new lcs.BLL.roles();
		lcs.Model.roles model=bll.GetModel(roles_id);
		this.lblroles_id.Text=model.roles_id.ToString();
		this.txtroles_name.Text=model.roles_name;
		this.txtroles_descripition.Text=model.roles_descripition;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtroles_name.Text.Trim().Length==0)
			{
				strErr+="roles_name不能为空！\\n";	
			}
			if(this.txtroles_descripition.Text.Trim().Length==0)
			{
				strErr+="roles_descripition不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int roles_id=int.Parse(this.lblroles_id.Text);
			string roles_name=this.txtroles_name.Text;
			string roles_descripition=this.txtroles_descripition.Text;


			lcs.Model.roles model=new lcs.Model.roles();
			model.roles_id=roles_id;
			model.roles_name=roles_name;
			model.roles_descripition=roles_descripition;

			lcs.BLL.roles bll=new lcs.BLL.roles();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
